import http from "../utils/httpRequest"

export default {
    httpGet(url, data) {
        return http({
            url: http.adornUrl(url),
            method: 'get',
            params: http.adornParams(data)
        }).then(({
            data
        }) => {
            if (data.code == 0) {
                return data
            } else {
                this.$message.error(data.msg);
            }
        })
    },
    httpPost(url, data) {
        return http({
            url: http.adornUrl(url),
            method: 'post',
            data: http.adornData(data)
        }).then(({
            data
        }) => {
            if (data.code == 0) {
                return data
            } else {
                this.$message.error(data.msg);
            }
        }).catch()
    },
    // 请求封装
    httpPostParams(url, data) {
        return http({
            url: http.adornUrl(url),
            method: 'post',
            params: http.adornParams(data)
        }).then(({
            data
        }) => {
            if (data.code == 0) {
                return data
            } else {
                this.$message.error(data.msg);
            }
        }).catch()
    },
}